function addInterface() {
    var interfaceType =$("#interfaceType").val();
    window.location.href="/interface/addInterfacePage?interfaceType="+interfaceType;
}

function modifyInterface() {
    var arr =$("#dataTable").bootstrapTable("getSelections");
    if(arr.length <=0){
        Ewin.alert("必须选择一条数据操作");
        return
    }
    if(arr.length >1){
        Ewin.alert("只能选择一个组件修改");
        return
    }
    var id =arr[0].id;
    window.location.href="/interface/modifyInterfacePage?id="+id;
}

function deleteInterface() {
    var arr =$("#dataTable").bootstrapTable("getSelections");
    if(arr.length <=0){
        Ewin.alert("必须选择一条数据操作");
        return
    }
    if(arr.length >1){
        Ewin.alert("只能选择一个组件修改");
        return
    }
    var id =arr[0].id;
    Ewin.confirm({message:"确认要删除组件信息吗?如果删除那么测试计划中的组件和用例也会失效!"}).on(function (e) {
        if(!e){
            return;
        }
        var url="/interface/deleteInterface";
        $.ajax({
            url:url,
            method:"post",
            data:{
                interfaceId:id
            },success:function (result) {
                if(result.success){
                    $("#dataTable").bootstrapTable("refresh")
                }else {
                    Ewin.alert(result.msg);
                }
            }
        })
    });
}

function testCasePage() {
    var arr =$("#dataTable").bootstrapTable("getSelections");
    if(arr.length <=0){
        Ewin.alert("必须选择一条数据操作");
        return
    }
    if(arr.length >1){
        Ewin.alert("只能选择一个组件修改");
        return
    }
    var id =arr[0].id;
    var interfaceType =$("#interfaceType").val();
    window.location.href="/testCase/page?id="+id+"&interfaceType="+interfaceType;
}

function runInterface() {
    var interfaces = $("#dataTable").bootstrapTable("getSelections");
    if (interfaces.length <= 0) {
        Ewin.alert("必须选择一条数据操作");
        return
    }
    /**
     * 把所有选择的测试用例放入一个数组里面去
     * **/
    var interfaceIds = [];
    for (var i = 0; i < interfaces.length; i++) {
        var interfaceId = interfaces[i].id;
        interfaceIds.push(interfaceId);
    }
    runTest.runTestByInterface(interfaceIds);
}